import { createRouter, createWebHistory, RouteRecordRaw,createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    children: [
      {
        path: '/',
        name: 'login',
        component: () => import('../views/Login.vue')
      },
      {
        path: '/index',
        name: 'index',
        component: () => import('../views/index.vue')
      },
      {
        path: '/column',
        name: 'column',
        component: () => import('../views/column.vue')
      },
      {
        path: '/detail',
        name: 'detail',
        component: () => import('../views/detail.vue')
      },
      {
        path: '/write',
        name: 'write',
        component: () => import('../views/write.vue')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('../views/my.vue')
      },
    ]
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue')
  },
  
]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})
// router.beforeEach((to,from,next) => {
//   if(to.path != '/' && !localStorage.getItem('token')){
//     next('/')
//   }else{
//     next('')
//   }
// })
export default router
